package org.test.json.bean;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

public class HTEdge implements Serializable{
	private String edgeName = "";
	
	public HTEdge(String edgeName){
		this.edgeName = edgeName;
	}
	
	public static Object deepClone(Object srcObj){
		Object ret = null;
		
		Object $s = null;
		Object _s = null;
		Object s = null;
		
		if(srcObj != null){
			try {
				ByteArrayOutputStream baos = new ByteArrayOutputStream();
				ObjectOutputStream oos = new ObjectOutputStream(baos);
				oos.writeObject(srcObj);
				
				byte[] byteArray = baos.toByteArray();
				ByteArrayInputStream bais = new ByteArrayInputStream(byteArray);
				ObjectInputStream ois = new ObjectInputStream(bais);
				ret = ois.readObject();
				
				baos.close();
				oos.close();
				bais.close();
				ois.close();
			} catch (Exception e) {
				e.printStackTrace();
			} 
			
		}
		
		return ret;
	}
	
	
	public static void main(String[] args) {
		HTEdge htEdge = new HTEdge("name1");
		HTEdge deepClone = (HTEdge)HTEdge.deepClone(htEdge);
	
		System.out.println(htEdge == deepClone);
		System.out.println(htEdge.edgeName+"||"+htEdge);
		System.out.println(deepClone.edgeName+"||"+deepClone);
	}
	
}
